//
//  UITextField+YTAdd.m
//  Elife
//
//  Created by 拓客营 on 2022/4/20.
//

#import "UITextField+YTAdd.h"

@implementation UITextField (YTAdd)

- (void)setPlaceholderFont:(UIFont *)font{
    [self setPlaceholderFont:font textColor:nil];
}
- (void)setPlaceholderTextColor:(UIColor *)color{
    [self setPlaceholderFont:nil textColor:color];
}
- (void)setPlaceholderFont:(UIFont *)font textColor:(UIColor *)color{
    if (!self.placeholder || [[self.placeholder stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0) {
        return;
    }
    NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:self.placeholder];
    if (font) {
        [mutAttStr addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, self.placeholder.length)];
    }
    if (color) {
        [mutAttStr addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, self.placeholder.length)];
    }
    [self setAttributedPlaceholder:mutAttStr];
}

@end
